package com.GUIWork;

import javax.swing.JFrame;
import com.dbConnection.*;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JSplitPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class RegUserFrame extends JFrame{
	
	RegUserFrame uframe = this;
	theConnection conn;
	
	public RegUserFrame(final theConnection conn) {
		setTitle("GTBay User");
		this.conn = conn;
		
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
		splitPane.setBounds(118, 77, 197, 140);
		panel.add(splitPane);
		
		JSplitPane splitPane_1 = new JSplitPane();
		splitPane_1.setOrientation(JSplitPane.VERTICAL_SPLIT);
		splitPane.setLeftComponent(splitPane_1);
		
		JButton btnPostNewItem = new JButton("Post New Item");
		btnPostNewItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				postItem pframe = new postItem(conn);
				pframe.setVisible(true);
				pframe.setBounds(100, 100, 450, 480);
				pframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				uframe.dispose();
			}
		});
		splitPane_1.setLeftComponent(btnPostNewItem);
		
		JButton btnSearchForItems = new JButton("Search For Items");
		btnSearchForItems.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				searchFrame sframe = new searchFrame(conn, null);
				sframe.setVisible(true);
				sframe.setBounds(100, 100, 450, 300);
				sframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				uframe.dispose();
			}
		});
		splitPane_1.setRightComponent(btnSearchForItems);
		
		JSplitPane splitPane_2 = new JSplitPane();
		splitPane_2.setOrientation(JSplitPane.VERTICAL_SPLIT);
		splitPane.setRightComponent(splitPane_2);
		
		JButton btnLogout = new JButton("Logout");
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				LoginFrame lframe = new LoginFrame(conn);
				lframe.setVisible(true);
				lframe.setBounds(100, 100, 450, 300);
				lframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				uframe.dispose();
			}
		});
		splitPane_2.setRightComponent(btnLogout);
		
		JButton btnViewAuctionResults = new JButton("View Auction Results");
		btnViewAuctionResults.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				auctionResults resultframe = new auctionResults(conn);
				resultframe.setVisible(true);
				resultframe.setBounds(100,100,450,300);
				resultframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				uframe.dispose();
			}
		});
		splitPane_2.setLeftComponent(btnViewAuctionResults);
		
	}
}
